<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <title>Title</title>
    <link rel="stylesheet" href="../static/plugins/layui/css/layui.css">

</head>
<style>
    .ok-body {
        padding: 10px
    }
</style>

<body>
<div class="ok-body">

    <blockquote class="layui-elem-quote layui-text">
        用户基本信息
    </blockquote>


    <form class="layui-form layui-form-pane" action="">

        <input type="hidden" name="id" id="deviceId" th:value="${id}">

        <div class="layui-form-item">

            <div class="layui-inline">
                <label class="layui-form-label">姓名</label>
                <div class="layui-input-inline">
                    <input type="text" name="username" readonly class="layui-input">
                </div>
            </div>

            <div class="layui-inline">
                <label class="layui-form-label">登录名称</label>
                <div class="layui-input-inline">
                    <input type="text" name="loginName" class="layui-input">
                </div>
            </div>
        </div>


        <div class="layui-form-item">

            <div class="layui-inline">
                <label class="layui-form-label">角色</label>
                <div class="layui-input-inline">
                    <select name="roleId" lay-verify="required">
                        <option value=""></option>
                    </select>
                </div>
            </div>

            <div class="layui-inline">
                <label class="layui-form-label">手机号</label>
                <div class="layui-input-inline">
                    <input type="text" name="phone" readonly class="layui-input">
                </div>
            </div>

        </div>

        <div class="layui-form-item">
            <div class="layui-inline">
                <input type="hidden" name="organizationId" lay-verify="required">
                <label class="layui-form-label">岗位</label>
                <div class="layui-input-inline">
                    <input type="text" id="organizationName" readonly class="layui-input">
                </div>
            </div>

            <div class="layui-inline">
                <label class="layui-form-label">到岗时间</label>
                <div class="layui-input-inline">
                    <input type="text" id="arrivalTime" name="arrivalTime" readonly class="layui-input">
                </div>
            </div>

        </div>


        <div class="layui-form-item">
            <div class="layui-inline">
                <label class="layui-form-label">维修职称</label>
                <div class="layui-input-inline">
                    <select name="titleId" lay-verify="required">
                        <option value=""></option>
                    </select>
                </div>
            </div>

            <div class="layui-inline">
                <label class="layui-form-label" style="font-size: smaller;">取得证书时间</label>
                <div class="layui-input-inline">
                    <input type="text" id="certificateTime" name="certificateTime" readonly class="layui-input">
                </div>
            </div>

        </div>

    </form>

</div>

<script src="../static/plugins/layui/layui.js"></script>
<script src="../static/js/jquery-3.2.1.min.js"></script>
<script src="../static/js/jquery.base64.js"></script>
<script src="../static/js/md5.js"></script>
<script src="../static/js/device.js"></script>

<script th:inline="none">
    layui.use(['form', 'laydate'], function () {
        var form = layui.form;
        var laydate = layui.laydate;
        var tableName = 'user';
        var id = $('#deviceId').val();


        if (id) {
            //表示是修改页面
            var param = 'current=1&pageSize=2&searchCol=id&searchValue=' + id;
            JJZ.named('username').attr('readonly');
            JJZ.requestTableData(tableName, param, function (data) {
                var result = data.records[0];
                JJZ.named('username').val(result.username);
                JJZ.named('loginName').val(result.loginName);
                JJZ.named('password').val(JJZ.SHOW_PASSWORD);
                JJZ.named('phone').val(result.phone);
                // JJZ.named('jobNum').val(result.jobNum);
                JJZ.named('arrivalTime').val(JJZ.FormatDate(result.arrivalTime, 'yyyy-MM-dd'));
                JJZ.named('certificateTime').val(JJZ.FormatDate(result.certificateTime, 'yyyy-MM-dd'));

                JJZ.named("organizationId").val(result.organizationId);
                $('#organizationName').val(result.organizationName);

                //初始角色下拉框
                JJZ.initSelect(JJZ.named('roleId'), '/role/dataGrid', function (noError) {
                    if (noError) {
                        JJZ.named('roleId').find('option').each(function (index, elem) {
                            $(elem).val() == result.roleId ? $(elem).attr("selected", "selected") : '';
                        });
                        form.render(); //更新表单
                    }
                });

                JJZ.initSelect(JJZ.named('titleId'), '/title/dataGrid', function (noError) {
                    if (noError) {
                        JJZ.named('titleId').find('option').each(function (index, elem) {
                            $(elem).val() == result.titleId ? $(elem).attr("selected", "selected") : '';
                        });
                        form.render();
                    }
                });
                form.render();
            });
        }

    });
</script>
</body>
</html>